﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MediPlatform.Domain.Order
{
    /// <summary>
    /// 问诊单主表
    /// </summary>
    public class ConsultationOrder
    {
        /// <summary>
        /// 主键，自增
        /// </summary>
        [Key]
        public long? Id { get; set; }

        /// <summary>
        /// 唯一问诊单编号
        /// </summary>
        [StringLength(64)]
        public string? OrderNo { get; set; }

        /// <summary>
        /// 患者用户ID
        /// </summary>

        public long? PatientId { get; set; }

        /// <summary>
        /// 接诊医生ID
        /// </summary>
        public long? DoctorId { get; set; }

        /// <summary>
        /// 就诊医院ID
        /// </summary>
        public long? HospitalId { get; set; }

        /// <summary>
        /// 科室ID
        /// </summary>
        public long? DepartmentId { get; set; }

        /// <summary>
        /// 问诊类型：1-视频问诊, 2-电话问诊, 3-图文问诊, 4-极速电话, 5-复诊开药
        /// </summary>
        public int? ConsultationType { get; set; } = 1;

        /// <summary>
        /// 订单状态：0-待支付, 1-进行中, 2-已完成, 3-已取消, 4-已退诊
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 预约时间（如视频问诊或电话问诊）
        /// </summary>
        public DateTime? AppointmentTime { get; set; }

        /// <summary>
        /// 提交时间
        /// </summary>
        public DateTime? SubmitTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 应付金额
        /// </summary>
        [Range(0, double.MaxValue)]
        public decimal? Fee { get; set; }

        /// <summary>
        /// 优惠金额
        /// </summary>
        public decimal? DiscountAmount { get; set; }

        /// <summary>
        /// 实际支付金额
        /// </summary>
        [Range(0, double.MaxValue)]
        public decimal? ActualPayment { get; set; }

        /// <summary>
        /// 支付方式：wechat, alipay, bank_card
        /// </summary>
        [StringLength(20)]
        public string? PaymentMethod { get; set; }

        /// <summary>
        /// 支付完成时间
        /// </summary>
        public DateTime? PaymentTime { get; set; }

        /// <summary>
        /// 退款金额
        /// </summary>
        public decimal? RefundAmount { get; set; }

        /// <summary>
        /// 退款完成时间
        /// </summary>
        public DateTime? RefundTime { get; set; }

        /// <summary>
        /// 取消原因
        /// </summary>
        public string? CancelReason { get; set; }

        /// <summary>
        /// 扩展信息，如医保结算信息
        /// </summary>
        public string? ExtraInfo { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 导航属性：患者信息
        /// </summary>
        public virtual User? Patient { get; set; }

        /// <summary>
        /// 导航属性：医生信息
        /// </summary>
        public virtual User? Doctor { get; set; }
    }
}
